<script type="text/javascript" src="{$base_dir}js/AJAX_Surgery_Equipment.js"></script>
<script type="text/javascript" src='{$base_dir}js/AJAX_Surgery.js'></script>
<script type="text/javascript">
{literal}	
	$(document).ready(function () {	
		/*$('#surgeryName').change(function(){
	    	var surgery_service_id = $('#surgeryName option:selected').val();
	    	
	    	if ( surgery_service_id == '' ) {
	    		$('#surgeryType').val('');
	    		
	    	} else {		    		
	    		$('#surgeryType').val($('#surgeryName option:selected').attr("ser_type"));		    		
	    	}		    	
		});*/

		addDatePicker('#surgeryDate_dd', '#surgeryDate_mm','#surgeryDate', false, false, true);
  
		$('#selectSurgeryName').click(function(){
			var buttons = {};
			buttons[_('Cancel')] = function() {	
				resetSelectSurgeryDialog();
				$(this).dialog('close');
			};
			buttons[_('Select')] = function() {	
				$('#surgeryName').val(getSelectedSurgeryName());
				$('#surgeryType').val(getSelectedSurgeryType());
				$('#h_surgeryName').val(getSelectedSurgeryId());
				$(this).dialog('close');
				resetSelectSurgeryDialog();
			};
			var title = _('SELECT SURGERY SERVICE');
			popUpSelectSurgeryService('get_surgery_service_dialog', title, null, null,buttons,null);
		});			  
	});
		
{/literal}
</script>

<link href="{$base_dir}css/autocomplete.css" type="text/css" rel="stylesheet">

<div id="editSurgery" class="form_container" style='margin-top: 10px'>
<form method="post" name="editSugeryForm" id="editSurgeryForm" action="../Surgery/editSurgery?sugeryId={$surgery->getId()}">
	<input type="hidden" id="surgeryId" name="surgeryId" value="{$surgery->getId()}">
	<input type="hidden" id="recordId" name="recordId" value="{$recordId}">
	<table id="surgeryInformation" cellpadding="0" cellspacing="0">
		<thead>
			<tr>
				<td><span style="text-transform: uppercase" class='label'>{translate}Surgical information{/translate}</span></td>
				<td colspan="3" align="right"><input type="button" name="surgery_equipment" id="surgery_equipment" onclick='javascript:activeEquipmentPage();' value="&gt;&gt; {translate}Input medicines, surgical instruments{/translate} &gt;&gt;"></td>
			</tr>
		</thead>
		<tbody>
		    <tr>
		        <td class='label'>{translate}Date of surgery{/translate} (*)</td>
		        <td colspan="3">
			        {if $surgery->getId()=='' || $surgery->getId()==0}
			        <input name="surgeryDate_{$datePart_0}" id="surgeryDate_{$datePart_0}" type="text" value="{$currentDate.0}" style="width: 21px;"><span class="label">-</span><input name="surgeryDate_{$datePart_1}" id="surgeryDate_{$datePart_1}" type="text" value="{$currentDate.1}" style="width: 21px;"><span class="label">-</span><input name="surgeryDate_{$datePart_2}" id="surgeryDate" type="text" value="{$currentDate.2}" style="width: 40px;">
			        <span class="label" style="width: 21px; color: #AAA;">({$datePart_0}-{$datePart_1}-{$datePart_2})</span>
			        {else}
			        <input name="surgeryDate_{$datePart_0}" id="surgeryDate_{$datePart_0}" type="text" value="{$surgeryDate.0}" style="width: 21px;"><span class="label">-</span><input name="surgeryDate_{$datePart_1}" id="surgeryDate_{$datePart_1}" type="text" value="{$surgeryDate.1}" style="width: 21px;"><span class="label">-</span><input name="surgeryDate_{$datePart_2}" id="surgeryDate" type="text" value="{$surgeryDate.2}" style="width: 40px;">
			        <span class="label" style="width: 21px; color: #AAA;">({$datePart_0}-{$datePart_1}-{$datePart_2})</span>
			        {/if}
		        </td>
		    </tr>
		    <tr>
		        <td class='label'>{translate}Surgery name{/translate} (*)</td>
		        <td>
		        	<!--<select name="surgeryName" id="surgeryName" style="width: 300px;">
		        	<option value='' >- - {translate}Select surgery name{/translate} - -</option>
		        	{foreach from=$surgeryServiceList item=curr}			        	
			        	{if $curr.id == $surgery_service_id}
			        		<option value='{$curr.id}' ser_type='{$curr.type}' selected="selected">{$curr.name}</option>
			        	{else}		        	
			        		<option value='{$curr.id}' ser_type='{$curr.type}' >{$curr.name}</option>
			        	{/if}			        					
					{/foreach}
		        	</select>-->
		        	<input type="text" readonly="readonly" id="surgeryName" name="surgeryName" style='width: 295px;' value='{$surgeryName}'/>
		        	<input id='selectSurgeryName' type="button" value="{translate}Select{/translate}">
		        	<input type="hidden"" id="h_surgeryName" name='h_surgeryName' value="{$surgery_service_id}">		        	
		        </td>
		        <td><span class="label">{translate}Type{/translate}</span></td>
		        <td>
		        	{if $surgery_service_id == ''}
	        			<input type="text" id='surgeryType' readonly="readonly" style='width: 100px;' />
	        		{else}
	        			<input type="text" id='surgeryType' readonly="readonly" style='width: 100px;' value="{$surgery_service_id_type}" />
	        		{/if}
		        	
		        </td>
		    </tr>
		    
		    <tr>
		        <td class='label'>{translate}Description{/translate}</td>
		        <td colspan="3">
		        	<input type="text" id="description" name="description" style='width: 295px;' value="{$surgery->getDescription()}" />
		        </td>
		    </tr>
		     <tr>
		        <td class='label'>{translate}Diagnosis{/translate} (*)</td>
		        <td colspan="3">
		        	<input type="text" name="surgeryDiagnosis" id="surgeryDiagnosis" style='width: 295px;' value="{$surgery->getDiagnosis()}">
		        </td>
		    </tr>
		    <tr>
		        <td class='label'>{translate}Insensible method{/translate} (*)</td>
		        <td colspan="3"><input type="text" name="anesthesia" id="anesthesia" value="{$surgery->getAnesthesia()}" style='width: 295px;'></td>
		    </tr>
		    <tr>
		        <td class='label'>{translate}Surgical method{/translate} (*)</td>
		        <td colspan="3"><input type="text" name="surgicalMethod" id="surgicalMethod" value="{$surgery->getMethod()}" style='width: 295px;'></td>
		    </tr>
		    <tr>
		        <td class='label'>{translate}Surgical happening{/translate}</td>
		        <td colspan="3"><input type="text" name="surgicalHappening" id="surgicalHappening" style='width: 295px;' value="{$surgery->getHappening()}"></td>
		    </tr>

		    <tr>
      			<td class='label' colspan="4">
      				{translate}Surgery team (Surgeon *, anesthetist *){/translate}&nbsp; &nbsp;
      				<a href="javascript: showSurgeryTeamTemplate();" title="{translate}Team template{/translate}"> 
      					<img src="../images/surgery_team.png" alt="{translate}Team template{/translate}" border="0" align="bottom"" />
      				</a>
      			</td>
      		</tr>
      		<tr>
         		<td class='label'>{translate}Role{/translate}</td>
       			<td colspan="3">
       				<select name="surgicalRole" id="surgicalRole" style="width: 300px;" onchange="javascript:getUsersByEmployeeType();">
       					{html_options options=$participantRoles}
       				</select>
       			</td>
       			
         	</tr>         	         	         	
         	<tr>
         		<td class='label'>{translate}Doctor's/Technician's name{/translate}</td>
         		<td colspan="3">         			
         			<select id="selectPeople" name="selectPeople" style="width: 300px;">
         			</select>&nbsp;&nbsp;
         			<a id="addPartToList" href="javascript:addParticipant()">
						<img class='imgBtn' src='../images/add_small.png' border='0' align='bottom'/>
					</a>
				</td>
         	</tr>
       		<tr>
       			<td colspan="4" valign="top" align="left">
       				<table class="grid" id="surgeryParticipants" cellpadding="0" cellspacing="0">
       					<thead>
       						<tr>
       							<th width="300px" align="center">{translate}Doctor's/Technician's name{/translate}</th>
       							<th width="300px" align="center">{translate}Role{/translate}</th>
       							<th width="30px" class='action last'>&nbsp;</th>
       						</tr>
       					</thead>
       					<tbody>
       						{foreach from=$participants key=role item=item}
       							{foreach from=$item item=participant}
			       			 <tr id="{$role}">       
				            	<td valign="top" class='first'>
				            		<span>{$participant.name}</span>
				            		<input type="text" name="personNames[]" id="personNames" value="{$participant.id}"  style="width: 140px; display: none"/>
				            	</td>
				            	<td valign="top">
				            		<span>{$participant.roleName}</span>
				            		<input type="text" name="roles[]" id="roles" value="{$role}" style="width: 140px; display: none"/>
				            	<td valign="top" class='action last'><a id="p_row_{$index++}" href="javascript:removeRole('p_row_{$index-1}')"><img class='imgBtn' src='../images/remove_small.png' border='0' title='{translate}Delete{/translate}'/></a></td>
			            	</tr>
			             	{/foreach}
      						{/foreach} 
       					</tbody>
       				</table>
      			</td>         			
       		</tr>
		    <tr>
		        <td colspan="4">
		        	<input id='saveSurgery' type="button" value="{translate}Save{/translate}">
		        	<span id='statusMessage' class='formAlertMsg' style="padding-left: 20px;"></span>
					<span id='successfulMessage' class='formAlertMsg' style="padding-left: 20px;"></span>
	        	</td>
		    </tr>
  		</tbody>
	</table>
</form>
</div>

{include file='surgery/general_surgery_team_template.html'}
{include file='surgery/element_div_get_surgery_service.html'}
<div id="surgery_equipment_div" style="display: none;">
</div>
